package main

import (
	// "github.com/neovim/go-client/nvim/plugin"

	"log"

	nvim "github.com/neovim/go-client/nvim"
)

// func hello(args []string) (string, error) {
// 	return "Hello " + strings.Join(args, " "), nil
// }
//
// func main() {
// 	plugin.Main(func(p *plugin.Plugin) error {
// 		p.HandleFunction(&plugin.FunctionOptions{Name: "Hello"}, hello)
// 		return nil
// 	})
// }

func main() {
	addr := "127.0.0.1:6666"
	if addr == "" {
		log.Fatal("NVIM_LISTEN_ADDRESS not set")
	}

	// Dial with default options.
	v, err := nvim.Dial(addr)
	if err != nil {
		log.Fatal(err)
	}

	// Cleanup on return.
	defer v.Close()

	currb, _ := v.CurrentBuffer()
	b := []byte("﵂")
	i := []byte("")
	k := []byte("")
	c := [][]byte{b, i, k}
	count, _ := v.BufferLineCount(currb)
	v.SetBufferLines(currb, 0, count, true, [][]byte{})
	v.SetBufferLines(currb, 0, 3, false, c)
	// bufs, err := v.Buffers()
	// if err != nil {
	// 	log.Fatal(err)
	// }

	// // Get the names using a single atomic call to Nvim.
	// names := make([]string, len(bufs))
	// b := v.NewBatch()
	// for i, buf := range bufs {
	// 	b.BufferName(buf, &names[i])
	// }
	// if err := b.Execute(); err != nil {
	// 	log.Fatal(err)
	// }

	// // Print the names.
	// for _, name := range names {
	// 	fmt.Println(name)
	// }
	// s := ""
	// curb, _ := v.CurrentBuffer()
	// b.BufferName(curb, &s)
	// currl, _ := v.CurrentLine()
	// fmt.Println(string(currl))
}
